<?php
/**
 * Created by PhpStorm.
 * User: liuwei
 * Date: 2022/12/16
 * Time: 14:19
 */

namespace App\Http\Controllers\Backend1;
use App\Services\Business\Models\Service;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Services\Business\Models\StrategyService;
use App\Http\Requests\Backend\ServiceRequest;



class ServiceController extends BaseController
{
 

    public function index(Request $request)
    {

        $services  = Service::all();
        return $this->successData(compact('services'));
    }
    public function store(ServiceRequest $request, Service $service){
        $data  =$request->filldata();
        $service->fill($data)->save();
        return $this->success("新增服务成功");
    }

    public function delete($id)
    {

        $service = StrategyService::query()->where('id', $id)->firstOrFail();
        $service->delete();
        return $this->success(__('删除服务成功'));
    }


    /**
     * @param ServiceRequest $request
     * @param $id
     * @return JsonResponse
     */
    public  function  update(ServiceRequest $request, $id){
        $faq = StrategyService::query()->where('id',$id)->firstOrFail();
        $faq ->fill($request->filldata())->update();
        return  $this->success(__('更新服务成功'));
    }




}